package learningThread.instance.lazy;

/**
 * 懒汉模式，线程不安全
 */
public class MyObject {

    private static MyObject instance;

    private MyObject() {

    }

    public static MyObject getInstance() {

        try {
            if (instance == null) {
                Thread.sleep(3000);
                instance = new MyObject();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return instance;
    }
}
